package com.chinasofti.project.service.user.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chinasofti.project.dal.mapper.BzUserMapper;
import com.chinasofti.project.dal.model.BzUser;
import com.chinasofti.project.service.user.PersonalDataService;

@Service("personalDataService")
public class PersonalDataServiceImpl implements PersonalDataService {
	@Autowired
	private BzUserMapper bzUserMapper;
	

	@Override
	public boolean toPersonalDataService(BzUser user) {
		if (isEmpty(user.getUserId()) && isEmpty(user.getUserBirthday()) && isEmpty(user.getUserNickname())
				&& isEmpty(user.getUserPhone()) && isEmpty(user.getUserTrueName())) {
			return false;
		} else {
			bzUserMapper.updateByPrimaryKeySelective(user);
			return true;
		}

	}

	@Override
	public BzUser queryPersonalData(int userId) {

		return bzUserMapper.selectByPrimaryKey(userId);

	}

	public boolean isEmpty(Object parameter){
		if (parameter == null || parameter == "" || (int) parameter == 0) {
			return true;
		}
		return false;
	}
	
}
